<?php 
$sql =	"SELECT
			  c.album_id,
			  c.order_number,
			  d.title
		  FROM
			  album AS c,
			  album_description AS d
		  WHERE
			  c.album_id = d.album_id
			  AND
			  d.lang_id = '".$_SESSION['lang_id']."'
			  AND
			  c.sef_url = '".$sef_url."' 
			  AND c.published
		  ";
$result = query($sql);
$row = mysql_fetch_object($result);

$sql =	"SELECT
			  category_id
		  FROM
			  album_to_category
		  WHERE
			  album_id = '".$row->album_id."'
		  AND 
			  category_id = 1
		  ";
$is_wedding = mysql_fetch_assoc(query($sql));


head(sth($row->title),'','');

if(!$_SESSION['zoom']) $_SESSION['zoom'] = 3;
?>

	<div id="topicons">
		<a class="icon home" href="<?=HTML_BASE?>"><span><?=__HOME?></span></a>
		<a class="icon about" href="<?=HTML_BASE.$_SESSION['lang']?>/about"><span><?=__ABOUT?></span></a>
		
		<a class="icon minus" href="#"><span><?=__ZOOMOUT?></span></a>
		<a class="icon plus" href="#"><span><?=__ZOOMIN?></span></a>
        
        <h1><?=stripslashes($row->title)?></h1>
	</div>
	<div id="lefticons">
	
   		<a class="icon <?=$_GET['prm1']?>" href="<?=HTML_BASE.$_SESSION['lang']?>/<?=$_GET['prm1']?>"><span><?=__BACK?></span></a>		
		<a class="icon price" href="<?=HTML_BASE.$_SESSION['lang']?>/prices#<?=$_GET['prm1']?>"><span><?=__PRICE_PHOTO?></span></a>
		<a class="icon contacts" href="<?=HTML_BASE.$_SESSION['lang']?>/contacts"><span><?=__CONTACTS?></span></a>
        
        <a class="icon fearless" href="http://www.fearlessphotographers.com/"><span><?=__MEMBER_OF?></span></a>
        
        <div style="top:3px; position:relative;" class="fb-like" data-href="<?=HTML_BASE.$_SESSION['lang'].'/'.$_REQUEST["prm1"].'/'.$sef_url?>" data-layout="box_count" data-action="like" data-show-faces="false" data-share="true"></div>
	</div>
	
	<div id="gallery">
    
    
    
    <?php
	if($row->title)
	{
	
	
	
	
	$dirFiles = array();
// opens images folder
if ($handle = opendir('albums/'.$row->album_id.'/thumbnail/')) {
    while (false !== ($file = readdir($handle))) {
		
		if ($file != "." && $file != ".." ) {
        	$dirFiles[] = $file;
        }

	}
	
	 closedir($handle);
}

sort($dirFiles);
	$i = 0;
	
	
	foreach($dirFiles as $filename)
{
      $title = '';
			  $title = sth(image_title($row->album_id,$filename));
			  $title = 'title="'.$title.'|'.$i.'"';
			  ?>
				  
                  <div class="gall<?=$_SESSION['zoom']?>" data-title="<?=urlencode(HTML_BASE.'albums/'.$row->album_id.'/'.$filename)?>"><a rel="gallery" href="<?=HTML_BASE?>albums/<?=$row->album_id?>/<?=$filename?>" <?=$title?> ><img src="<?=HTML_BASE?>albums/<?=$row->album_id?>/thumbnail/<?=$filename?>" alt=""></a><span id="id_<?=$i?>" <?=ip_likes($row->album_id,$filename)?> onclick="like('<?=$i?>','<?=$row->album_id?>','<?=$filename?>');"><?=image_likes($row->album_id,$filename)?></span></div>
			  <?php
			  $i++;
}
	
	
	
	
	
	/*while ( false != ( $filename = readdir($dir)))
		   { 
		   if (( $filename != "." ) and ( $filename != ".." ))
			  { 
			  $title = '';
			  $title = sth(image_title($row->album_id,$filename));
			  $title = 'title="'.$title.'|'.$i.'"';
			  ?>
				  
                  <div class="gall<?=$_SESSION['zoom']?>"><a rel="gallery" href="<?=HTML_BASE?>albums/<?=$row->album_id?>/<?=$filename?>" <?=$title?> ><img src="<?=HTML_BASE?>albums/<?=$row->album_id?>/thumbnail/<?=$filename?>" alt="<?=$filename?>"></a><span id="id_<?=$i?>" <?=ip_likes($row->album_id,$filename)?> onclick="like('<?=$i?>','<?=$row->album_id?>','<?=$filename?>');"><?=image_likes($row->album_id,$filename)?></span></div>
			  <?php
			  $i++;	 
			  }
		   }

	
	*/

	
	
	}
	?>
		
        
        
	</div>
    
<script type="text/javascript" src="<?=HTML_BASE?>fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="<?=HTML_BASE?>fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?=HTML_BASE?>fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript">
	$(document).ready(function() {
		$("a[rel=gallery]").fancybox({
			'titlePosition' : 'over',
			'centerOnScroll': true,
			'overlayOpacity': 1,
			'overlayColor': '#000',
			'titleFormat': formatTitle
		});
		
		function formatTitle(title) {
			
			var allelemnt = title.split("|");
			var newtitle = allelemnt[0];
			var id = allelemnt[1];
			
			//alert($('#id_'+id).parent().attr('data-title'));
			return '<div class="fancytitle">'+newtitle+'<a href="//www.pinterest.com/pin/create/button/?url=<?=urlencode(HTML_BASE.$_SERVER['QUERY_STRING'])?>&media='+$('#id_'+id).parent().attr('data-title')+'&description='+newtitle+'" data-pin-do="buttonPin" data-pin-shape="round"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_round_red_16.png" /></a> <span onclick="'+$('#id_'+id).attr('onclick')+'" class="'+$('#id_'+id).attr('class')+'" id="fan_'+id+'">'+$('#id_'+id).html()+'</span></div>';
		}
	});
	
	function like(id,album,image)
	{
		 $.ajax({
				type: "POST",
				url: "<?=HTML_BASE?>like.php",
				data: "album=" + album + "&image=" + image,
				success: function(msg){
					$('#id_'+id).html(msg);
					$('#id_'+id).addClass( "like" );
					
					$('#fan_'+id).html(msg);
					$('#fan_'+id).addClass( "like" );
				},
				error: function(msg){
					alert(msg);
				}
			});	
	}
</script>
	
<?php

foot();
?>